package com.sky.web.admin;

import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@Slf4j
@RequestMapping("/admin/workspace")
public class workSpaceController {

    @Autowired
    private ReportService reportService;

    //今日运营数据
    @GetMapping("/businessData")
    public Result businessData() {
        //1.获取今日的日期
        LocalDate today = LocalDate.now();
        //2.调用业务层方法获取数据
        BusinessDataVO vo = reportService.businessData(today);
        //3.返回结果
        return Result.success(vo);
    }

    //查询订单管理数据
    @GetMapping("/overviewOrders")
    public Result turnoverStatistics() {
        //1.获取今日的日期
        LocalDate today = LocalDate.now();
        //2.调用业务层方法获取数据
        OrderOverViewVO vo = reportService.overviewOrders(today);
        //3.返回结果
        return Result.success(vo);
    }

    //菜品总览（作业）
    @GetMapping("/overviewDishes")
    public Result overviewDishes() {
        String temp="dish";
        //2.调用业务层方法获取数据
        DishOverViewVO vo=reportService.countStatus(temp);
        log.info("返回结果{}",vo);
        //3.返回结果
        return Result.success(vo);
    }


    //套餐总览（作业）
    @GetMapping("/overviewSetmeals")
    public Result overviewSetmeals() {
        String temp="setmeal";
        //2.调用业务层方法获取数据
        DishOverViewVO vo=reportService.countStatus(temp);
        log.info("返回结果{}",vo);
        //3.返回结果
        return Result.success(vo);
    }
}
